<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :advOptions="[]"
      :dictMap="dictMapAsync"
      :formOptions="formOptions"
      :outputQueryParams="queryParams"
      :queryParams="queryParams"
    ></Ht-search-form>

    <ht-table
      ref="dataTable"
      :dictMap="dictMap"
      :multi-select="false"
      :opButtonList="opButtonList"
      :queryParams="queryParams"
      :reqConfig="regConfig"
      :showSerialNumber="false"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column align="left" fixed="right" label="操作" width="50">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      :close-on-click-modal="false"
      :title="title"
      center
      :visible.sync="open"
      v-if="open"
      append-to-body
      width="1024px"
    >
      <el-form ref="detailForm" :disabled="true" :model="detailForm" label-width="160px">
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>业务查询信息详情</span>
          </div>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="查询流水号" prop="id">
                <el-input v-model="detailForm.id" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="查询类型" prop="inqType">
                <el-select style="width: 100%" v-model="detailForm.inqType" placeholder="查询类型">
                  <el-option
                    v-for="dict in dictMap.INQ_TYPE_314_QUERY"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="内部机构号" prop="brno">
                <el-select style="width: 100%" v-model="detailForm.brno" placeholder="内部机构号">
                  <el-option
                    v-for="dict in dictMap['Cnaps2Dict.CP2_BRNO']"
                    :key="dict.value"
                    :label="`${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgId">
                <el-input v-model="detailForm.pkgId" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="工作日期" prop="workdate">
                <el-date-picker v-model="detailForm.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="cpgdate">
                <el-date-picker v-model="detailForm.cpgdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="来往标识" prop="drct">
                <el-select style="width: 100%" v-model="detailForm.drct" placeholder="来往标识">
                  <el-option
                    v-for="dict in dictMap.DRCTCODE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="系统编号" prop="sysCode">
                <el-select style="width: 100%" v-model="detailForm.sysCode" placeholder="系统编号">
                  <el-option
                    v-for="dict in dictMap.ORGAN_SYSTYPE_310"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起直接参与机构号" prop="directSender">
                <el-input v-model="detailForm.directSender" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="发起参与机构名称" prop="directSenderName">
                <el-input v-model="detailForm.directSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起间接参与机构号" prop="indirectSender">
                <el-input v-model="detailForm.indirectSender" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="发起间接参与机构名" prop="indirectSenderName">
                <el-input v-model="detailForm.indirectSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="接收直接参与机构号" prop="directRecver">
                <el-input v-model="detailForm.directRecver" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="接收直接参与机构名" prop="directRecverName">
                <el-input v-model="detailForm.directRecverName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="接收间接参与机构号" prop="indirectRecver">
                <el-input v-model="detailForm.indirectRecver" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="接收间接参与机构名" prop="indirectRecverName">
                <el-input v-model="detailForm.indirectRecverName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="通讯状态" prop="status">
                <el-select style="width: 100%" v-model="detailForm.status" placeholder="通讯状态">
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="业务状态" prop="txnStatus">
                <el-select style="width: 100%" v-model="detailForm.txnStatus" placeholder="业务状态">
                  <el-option
                    v-for="dict in dictMap.TXN_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="中心状态" prop="procStatus">
                <el-select style="width: 100%" v-model="detailForm.procStatus" placeholder="中心状态">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="报文接收时间" prop="rcvTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.rcvTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="报文发送时间" prop="sndTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.sndTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="查复内容" prop="rspContent">
                <el-input type="textarea" v-model="detailForm.rspContent" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="备注" prop="remarks">
                <el-input type="textarea" v-model="detailForm.remarks" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>业务查询申请信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="oriId">
                <el-input v-model="detailForm.oriId" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="oriPkgId">
                <el-input v-model="detailForm.oriPkgId" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="报文类型" prop="oriMsgType">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.oriMsgType === null || detailForm.oriMsgType === undefined
                      ? ''
                      : detailForm.oriMsgType + '-' + detailForm.oriMsgTypeDesc
                  "
                  placeholder="报文类型"
                  :disabled="true"
                ></el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起参与机构号" prop="oriSender">
                <el-input v-model="detailForm.oriSender" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="发起参与机构名" prop="oriSenderName">
                <el-input v-model="detailForm.oriSenderName" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>原交易信息</span>
          </div>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易流水号/批次号" prop="oriIdTrue">
                <el-input v-model="detailForm.oriIdTrue" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原交易报文标识号" prop="txnOriPkgId">
                <el-input v-model="detailForm.txnOriPkgId" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易明细标识号" prop="txnOriDtlNo">
                <el-input v-model="detailForm.txnOriDtlNo" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易报文类型" prop="txnOriMsgType">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.txnOriMsgType === null || detailForm.txnOriMsgType === undefined
                      ? ''
                      : detailForm.txnOriMsgType + '-' + detailForm.txnOriMsgTypeDesc
                  "
                  placeholder="原交易报文类型"
                  :disabled="true"
                ></el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="原交易业务类型" prop="txnOriBizCtgy">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.txnOriBizCtgy === null || detailForm.txnOriBizCtgy === undefined
                      ? ''
                      : detailForm.txnOriBizCtgy + '-' + detailForm.txnOriBizCtgyDesc
                  "
                  placeholder="原交易报文类型"
                  :disabled="true"
                ></el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易直接发起机构号" prop="txnOriSender">
                <el-input v-model="detailForm.txnOriSender" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原交易直接发起机构名" prop="txnOriSenderName">
                <el-input v-model="detailForm.txnOriSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易发起间接参与机构号" prop="txnOriIndirectSender">
                <el-input v-model="detailForm.txnOriIndirectSender" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原交易发起间接参与机构名" prop="txnOriIndirectSenderName">
                <el-input v-model="detailForm.txnOriIndirectSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易接收间接参与机构号" prop="txnOriIndirectRecver">
                <el-input v-model="detailForm.txnOriIndirectRecver" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原交易接收间接参与机构名" prop="txnOriIndirectRecverName">
                <el-input v-model="detailForm.txnOriIndirectRecverName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易货币" prop="curcd">
                <el-input v-model="detailForm.curcd" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="交易金额" prop="amount">
                <ht-amount-input v-model="detailForm.amount" placeholder="交易金额"></ht-amount-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span></span>
          </div>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="录入操作员" prop="mdTlrno">
                <el-input v-model="detailForm.mdTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="录入时间" prop="mdTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.mdTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="审核操作员" prop="audTlrno">
                <el-input v-model="detailForm.audTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="审核时间" prop="audTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.audTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="审核附言" prop="audRemarks">
                <el-input type="textarea" v-model="detailForm.audRemarks" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

      <div slot="footer" align="center" class="dialog-footer">
        <el-button @click="printDetail">打 印</el-button>
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { apiUrlConfigQueryQuery, inquiryResponseQueryDetail } from "@/api/cnaps/ccms/315";
import { listPageMixin } from "@/libs/listPageMixin";
import HtAmountInput from "@/views/components/HtAmountInput";
import { mapGetters } from "vuex";

export default {
  name: "InquiryResponseQuery",
  mixins: [listPageMixin],
  components: { HtAmountInput },

  computed: {
    ...mapGetters(["globalBusData"]),
  },
  created() {
    this.$set(this.queryParams, "brno", this.globalBusData.brno);
  },
  watch: {
    globalBusData: {
      handler(val) {
        this.$set(this.queryParams, "brno", val.brno);
      },
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        idSeqNo: undefined,
        brno: undefined,
        cpgdate: undefined,
        cpgdate2: undefined,
        workdate: undefined,
        workdate2: undefined,
        sysCode: undefined,
        drct: undefined,
        status: undefined,
        indirectSender: undefined,
        indirectRecver: undefined,
      },
      // 搜索
      formOptions: [],
      //
      searchFormDictList: [
        "SYS_CODE",
        "DRCTCODE",
        "PKG_STATUS",
        "ORGAN_SYSTYPE_310",
        "INQ_TYPE_314_QUERY",
        "PROCESSSTATUS",
        "TXN_STATUS",
        "Cnaps2Dict.CP2_BRNO",
      ],
      // 列信息
      regConfig: apiUrlConfigQueryQuery,

      tableBindColumns: [
        { prop: "brno", label: "内部机构号", dictCode: "Cnaps2Dict.CP2_BRNO", sortable: false },
        { prop: "status", label: "通讯状态", dictCode: "PKG_STATUS" },
        { prop: "id", label: "查询流水号", width: "180" },
        { prop: "sysCode", label: "系统编号", dictCode: "SYS_CODE", width: "180", sortable: false },
        { prop: "cpgdate", label: "CPG日期", type: "date" },
        { prop: "workdate", label: "工作日期", type: "date" },
        { prop: "indirectSender", label: "发起间接参与机构", width: "150" },
        { prop: "indirectRecver", label: "接收间接参与机构", width: "150" },
        { prop: "drct", label: "来往账标识", dictCode: "DRCTCODE", sortable: false },
      ],
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "idSeqNo",
        defaultAttr: {
          size: "small",
          label: "查询流水号",
          placeholder: "请输入查询流水号",
        },
      },
      {
        type: "search-dept-tree",
        prop: "brno",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG开始日期", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dict",
        dict: "SYS_CODE",
        prop: "sysCode",
        defaultAttr: {
          size: "small",
          label: "系统编号",
          placeholder: "请输入系统编号",
        },
      },

      {
        type: "dict",
        dict: "DRCTCODE",
        prop: "drct",
        defaultAttr: {
          size: "small",
          label: "来往标识",
          placeholder: "请输入来往标识",
        },
      },

      {
        type: "dict",
        dict: "PKG_STATUS",
        prop: "status",
        defaultAttr: {
          size: "small",
          label: "通讯状态",
          placeholder: "请输入通讯状态",
        },
      },

      {
        type: "input",
        prop: "indirectSender",
        defaultAttr: {
          size: "small",
          label: "查询发起间接参与机构",
          placeholder: "请输入发起间接参与机构",
        },
      },

      {
        type: "input",
        prop: "indirectRecver",
        defaultAttr: {
          size: "small",
          label: "查询接收间接参与机构",
          placeholder: "请输入接收间接参与机构",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "业务查复信息查询明细";
      inquiryResponseQueryDetail(row.id).then((response) => {
        this.detailForm = response.result;
        this.open = true;
      });
    },

    //打印
    printDetail() {
      this.$print(this.$refs["detailForm"]);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
